import { ColumnGroupType, ColumnType } from "antd/es/table"

const getDateCircle = (start: string, end: string) => {
	const format = (str: string) => `${str.substring(0, 4)}-${str.substring(4, 6)}-${str.substring(6, 8)}`
	return `${format(start.toString())} - ${format(end.toString())}`
}

export const agencyIncomeStatementColumns = (
	newFormat: (arg: string) => string
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	agencyIncomeStatementCycleDate: {
		title: newFormat("funds.fund_audit.settlement_period"),
		dataIndex: "cycleDate",
		align: "center",
		fixed: true,
		width: 180,
		render: (_: any, record: any) => getDateCircle(record.cycleStatrtDate, record.cycleEndDate)
	},
	agencyIncomeStatementProfitRatio: {
		title: newFormat("common.profit_ratio"),
		dataIndex: "seePopup",
		key: "seePopup",
		width: 180,
		align: "center"
	},
	agencyIncomeStatementIncomeAmount: {
		title: newFormat("report.person_rebate_amount_label"),
		dataIndex: "incomeAmount",
		key: "incomeAmount",
		align: "center",
		width: 150
	},
	agencyIncomeStatementAjustAmount: {
		title: newFormat("report.adjust_amount"),
		dataIndex: "ajustAmount",
		key: "ajustAmount",
		align: "center",
		width: 150
	},
	agencyIncomeStatementServiceCharge: {
		dataIndex: "dzPumpContribution",
		key: "dzPumpContribution",
		align: "center",
		width: 150
	},
	agencyIncomeStatementInsuredNetAmount: {
		title: newFormat("funds.fund_audit.direct_agency_team_share_amount"),
		dataIndex: "insuredNetAmount",
		key: "insuredNetAmount",
		align: "center",
		width: 180
	}
})
